--------------------------------------------------------------------------------
-- This package is part of a thin Ada binding to the GNU Multiple Precision
-- Library. See <http://gmplib.org/>.
-- It simply translates in Ada some target-dependent definitions of the C
-- header file : gmp.h
--
-- Copyright (C) 2009 Vincent DIEMUNSCH.
-- GNU General Public License.
--
-- This program is free software: you can redistribute it and/or modify it under
-- the terms of the GNU General Public License as published by the Free Software
-- Foundation, either version 3 of the License, or (at your option) any later
-- version.
--
-- This file is distributed in the hope that it will be useful, but WITHOUT ANY
-- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License along with
-- this program.  If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------------
--
-- THE SIZES OF TYPES DEFINED HERE CORRESPOND TO A 32 BITS X86 ARCHITECTURE.
--

with Interfaces.C;  use Interfaces.C;

package MP_x86_32bits is

   ---------
   -- GMP --
   ---------

   type mp_limb_t is new unsigned_long;
   -- " Usually a limb is implemented as a long. " (GMP Manual).

   type mp_size_t is new long;
   -- if it's not a cray (except CRAYMPP), it should be that !!
   -- __GMP_MP_SIZE_T_INT = 0 !
   -- " Counts of limbs are represented in the C type mp_size_t. Currently this
   --   is normally a long, but on some systems it is an int for efficiency. "

   type mp_exp_t is new long;
   -- " The floating point functions accept and return exponents in the C type
   --   mp_exp_t. Currently this is usually a long, but on some systems it is
   --   an int for efficiency. "

   -- "Also, in general unsigned long is used for bit counts and ranges, and
   -- size_t is used for byte or character counts."

   ----------
   -- MPFR --
   ----------

   -- Define precision :
   MPFR_PREC_MIN : constant := 2;
   MPFR_PREC_MAX : constant := unsigned_long'Last;
   type mpfr_prec_t is new unsigned_long range MPFR_PREC_MIN .. MPFR_PREC_MAX;
   -- Since __GMP_MP_SIZE_T_INT = 0, for 32 bits Intel
   -- and therefore  _MPFR_PREC_FORMAT = 3

   -- Largest Integer Size :
   type intmax_t is new Long_Long_Integer;
   -- 1) GNU C defines in stdint.h intmax_t as "long long int" for 32 bits
   --    (but, BE CAREFUL, as "long int" for a 64 bits architecture)
   -- 2) GNAT simply defines Long_Long_Integers as "long long int".

private

   pragma Convention (C, mp_exp_t);
   pragma Convention (C, mp_limb_t);
   pragma Convention (C, mp_size_t);

   pragma Convention (C, mpfr_prec_t);
   pragma Convention (C, intmax_t);

end MP_x86_32bits;
